﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Smart_Archives_Api.Entity
{
    public partial class SaContext : DbContext
    {
        public SaContext()
        {
        }

        public SaContext(DbContextOptions<SaContext> options)
            : base(options)
        {
        }

        public virtual DbSet<SecurityDevice> SecurityDevice { get; set; }
        public virtual DbSet<SecurityDeviceCategory> SecurityDeviceCategory { get; set; }
        public virtual DbSet<SecurityDeviceRecord> SecurityDeviceRecord { get; set; }
        public virtual DbSet<TLog> TLog { get; set; }
        public virtual DbSet<TMessageReocrd> TMessageReocrd { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
                optionsBuilder.UseSqlServer("server=192.168.1.57;user id=sa;password=@dmin123;database=testDB");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");

            modelBuilder.Entity<SecurityDevice>(entity =>
            {
                entity.ToTable("Security_Device");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.ChannelId).HasColumnName("channel_id");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.DeviceModel)
                    .HasColumnName("device_model")
                    .HasMaxLength(200);

                entity.Property(e => e.DeviceType).HasColumnName("device_type");

                entity.Property(e => e.ExtranetIp)
                    .HasColumnName("extranet_ip")
                    .HasMaxLength(30);

                entity.Property(e => e.ExtranetPort).HasColumnName("extranet_port");

                entity.Property(e => e.Factory)
                    .HasColumnName("factory")
                    .HasMaxLength(50);

                entity.Property(e => e.IntranetIp)
                    .HasColumnName("intranet_ip")
                    .HasMaxLength(30);

                entity.Property(e => e.Location)
                    .HasColumnName("location")
                    .HasMaxLength(100);

                entity.Property(e => e.LoginName)
                    .HasColumnName("login_name")
                    .HasMaxLength(50);

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasMaxLength(100);

                entity.Property(e => e.Password)
                    .IsRequired()
                    .HasColumnName("password")
                    .HasMaxLength(50);

                entity.Property(e => e.Port).HasColumnName("port");

                entity.Property(e => e.Remarks)
                    .HasColumnName("remarks")
                    .HasMaxLength(200);

                entity.Property(e => e.Rtsp)
                    .HasColumnName("rtsp")
                    .HasMaxLength(200);

                entity.Property(e => e.SecurityCategoryId).HasColumnName("security_category_id");

                entity.Property(e => e.SerialNumber)
                    .HasColumnName("serial_number")
                    .HasMaxLength(100);

                entity.Property(e => e.Status).HasColumnName("status");

                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasColumnType("datetime");
            });

            modelBuilder.Entity<SecurityDeviceCategory>(entity =>
            {
                entity.ToTable("Security_Device_Category");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.Name)
                    .HasColumnName("name")
                    .HasMaxLength(50);

                entity.Property(e => e.ParentId).HasColumnName("parent_id");

                entity.Property(e => e.Status).HasColumnName("status");

                entity.Property(e => e.Type).HasColumnName("type");

                entity.Property(e => e.UpdateTime)
                    .HasColumnName("update_time")
                    .HasColumnType("datetime");
            });

            modelBuilder.Entity<SecurityDeviceRecord>(entity =>
            {
                entity.ToTable("Security_Device_Record");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.EventAddress)
                    .HasColumnName("event_address")
                    .HasMaxLength(50);

                entity.Property(e => e.EventTime)
                    .HasColumnName("event_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.EventType).HasColumnName("event_type");

                entity.Property(e => e.GuestIdCard)
                    .HasColumnName("guest_id_card")
                    .HasMaxLength(50);

                entity.Property(e => e.GuestMobile)
                    .HasColumnName("guest_mobile")
                    .HasMaxLength(30);

                entity.Property(e => e.GuestName)
                    .HasColumnName("guest_name")
                    .HasMaxLength(10);

                entity.Property(e => e.ImageUrl)
                    .HasColumnName("image_url")
                    .HasMaxLength(255);

                entity.Property(e => e.SecurityDeviceId).HasColumnName("security_device_id");

                entity.Property(e => e.VideoUrl)
                    .HasColumnName("video_url")
                    .HasMaxLength(255);
            });

            modelBuilder.Entity<TLog>(entity =>
            {
                entity.HasKey(e => e.LogId);

                entity.ToTable("t_Log");

                entity.Property(e => e.LogId)
                    .HasColumnName("Log_Id")
                    .ValueGeneratedNever();

                entity.Property(e => e.LogChangMark).HasColumnName("Log_ChangMark");

                entity.Property(e => e.LogContent)
                    .HasColumnName("Log_Content")
                    .HasColumnType("text");

                entity.Property(e => e.LogIp)
                    .HasColumnName("Log_IP")
                    .HasMaxLength(100);

                entity.Property(e => e.LogPath)
                    .HasColumnName("Log_Path")
                    .HasMaxLength(1000);

                entity.Property(e => e.LogRecordGuid)
                    .HasColumnName("Log_RecordGUID")
                    .HasMaxLength(36);

                entity.Property(e => e.LogTime)
                    .HasColumnName("Log_Time")
                    .HasColumnType("datetime");

                entity.Property(e => e.LogType)
                    .IsRequired()
                    .HasColumnName("Log_Type")
                    .HasMaxLength(20);

                entity.Property(e => e.LogUser).HasColumnName("Log_User");
            });

            modelBuilder.Entity<TMessageReocrd>(entity =>
            {
                entity.ToTable("t_Message_Reocrd");

                entity.Property(e => e.Id).ValueGeneratedNever();

                entity.Property(e => e.Datetime)
                    .HasColumnName("datetime")
                    .HasColumnType("date");

                entity.Property(e => e.Message)
                    .IsRequired()
                    .HasColumnName("message")
                    .HasMaxLength(1000);

                entity.Property(e => e.Type).HasColumnName("type");
            });
        }
    }
}
